//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    public class PrintSettings : IOfficeXmlSerializable
    {
        private PageMargins pageMargins;

        private PageSetup pageSetup;

        public PageMargins PageMargins
        {
            get { return pageMargins; }
            set { pageMargins = value; }
        }

        public PageSetup PageSetup
        {
            get { return pageSetup; }
            set { pageSetup = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("printSettings"))
            {
                c.PassAttributes();
                if (c.ReaderLocalName == "headerFooter")
                    c.Reader.ReadOuterXml(); //\\ c.WarnIf("headerFooter");
                PageMargins = c.ReadOptionalElement<PageMargins>("pageMargins");
                PageSetup = c.ReadOptionalElement<PageSetup>("pageSetup");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("printSettings"))
            {
                c.WarnIf("headerFooter");
                c.WriteOptionalElement(PageMargins);
                c.WriteOptionalElement(PageSetup);
            }
        }

        #endregion
    }
}